package org.kineticsproject.visualizations;


import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;


//import hci.JCheckBoxExt;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;



public class ChartPanelExt extends ChartPanel implements ActionListener
{
	public enum ChartType{SINGLEPLOT_MULTIPLEAXIS, SINGLEPLOT_SINGLEAXIS};
	
	private String 		chartTitle;
	private String 		tabTitle;
	private ChartType 	charType;

	public ChartPanelExt(JFreeChart chart)
	{
		super(chart);
		chartTitle = "";
		tabTitle   = "";
	}
	
	public ChartPanelExt(JFreeChart chart, String chartTitle, String tabTitle)
	{
		super(chart);
		this.chartTitle = chartTitle;
		this.tabTitle   = tabTitle;
	}

	public String getChartTitle() {
		return chartTitle;
	}

	public void setChartTitle(String chartTitle) {
		this.chartTitle = chartTitle;
	}

	public String getTabTitle() {
		return tabTitle;
	}

	public void setTabTitle(String tabTitle) {
		this.tabTitle = tabTitle;
	}
	
	public void actionPerformed(ActionEvent e)
	{
		Class jchkboxclass = JCheckBoxExt.class;
		
		if (jchkboxclass.isInstance(e.getSource())) // check that a JCheckBoxExt performed the action
		{
			if (this.getCharType().compareTo(this.charType.SINGLEPLOT_MULTIPLEAXIS) == 0)
			{
			JCheckBoxExt jchk = (JCheckBoxExt)e.getSource();		
			jchk.getRenderer().setSeriesVisible(new Boolean(jchk.isSelected()));
			jchk.getRenderer().setItemLabelsVisible(new Boolean(jchk.isSelected()));
			jchk.getRenderer().setSeriesVisibleInLegend(new Boolean(jchk.isSelected()));
			jchk.getAxis().setVisible(new Boolean(jchk.isSelected()));

			}
			else if (this.getCharType().compareTo(this.charType.SINGLEPLOT_SINGLEAXIS) == 0)
			{
			    
			    
				//JCheckBoxExt jchk = (JCheckBoxExt)e.getSource();
				//jchk.getRenderer().setSeriesVisible(jchk.getSeries().getIndex(), new Boolean(jchk.isSelected()));
				
			}
		
		}
		super.actionPerformed(e);
	}

	public ChartType getCharType() {
		return charType;
	}

	public void setCharType(ChartType charType) {
		this.charType = charType;
	}
	

}
